package org.sunrise.game.game.modules;

import com.alibaba.fastjson2.TypeReference;
import lombok.Getter;
import lombok.Setter;
import org.sunrise.game.game.annotation.HumanModule;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Getter
@Setter
public class ItemModule extends BaseModule {
    private Map<Integer, Integer> map = new HashMap<>();
    private List<Integer> list = new ArrayList<>();
    private int lv = 0;

    public ItemModule(String humanId) {
        super(humanId);
    }

    @Override
    public void init() {
        map.put(1, 100);
        list.add(200);
        list.add(300);
        lv = 999;
    }

    @Override
    public void load() {
        getDbData("map", new TypeReference<HashMap<Integer, Integer>>() {}, value -> map = value );
        getDbData("list", new TypeReference<ArrayList<Integer>>() {}, value -> list = value);
        getDbData("lv", new TypeReference<Integer>() {}, value -> lv = value);
    }

    @Override
    public void save() {
        putDbData("map", map);
        putDbData("list", list);
        putDbData("lv", lv);
    }

    @Override
    public void sendToClient() {
        super.sendToClient();
    }

    @Override
    public void dailyReset() {
        super.dailyReset();
    }

    @Override
    public void weekReset() {
        super.weekReset();
    }
}
